-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Move all LLVM externs into the rustc_llvm crate #142897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in compiler/rustc_codegen_llvm/src/builder/autodiff.rs cc @ZuseZ4 These commits modify the If this was unintentional then you should revert the changes before this PR is merged. Some changes occurred in compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs cc @ZuseZ4 Some changes occurred in coverage instrumentation. cc @Zalathar |
The job Click to see the possible cause of the failure (guessed by this bot)
|
"T-release", | ||
"requires-nightly", | ||
] | ||
exclude_labels = ["P-*", "T-infra", "T-release", "requires-nightly"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please revert all formatting changes?
☔ The latest upstream changes (presumably #143026) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only skimmed this so far, but I think there are a few things we can do that will reduce some of the churn.
(The smaller we can make this, the more likely I'll be able to review it properly!)
impl LLVMRustResult { | ||
pub(crate) fn into_result(self) -> Result<(), ()> { | ||
impl LLVMRustResultExt for LLVMRustResult { | ||
fn into_result(self) -> Result<(), ()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could move to rustc_llvm
, maybe in mod impls
, so it's still an inherent method. Then you won't need the use ...Ext as _
additions.
@@ -229,16 +224,19 @@ pub(crate) fn set_thread_local_mode(global: &Value, mode: ThreadLocalMode) { | |||
} | |||
} | |||
|
|||
impl AttributeKind { | |||
pub(crate) trait AttributeExt { | |||
fn create_attr(self, llcx: &Context) -> &Attribute; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, both of these create_attr
methods could be inherent in rustc_llvm
.
@@ -2,8 +2,9 @@ | |||
|
|||
use std::ffi::CString; | |||
|
|||
use rustc_llvm::ffi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe all these places that previously used coverageinfo::ffi
should rename the new path, so they don't need so much code churn otherwise:
use rustc_llvm::ffi; | |
use rustc_llvm::ffi::coverageinfo as ffi; |
@@ -3,7 +3,7 @@ use rustc_middle::mir::coverage::{CounterId, CovTerm, ExpressionId}; | |||
/// Must match the layout of `LLVMRustCounterKind`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the new filename -- when there are no further submodules, I'd prefer not to use mod.rs
, so this should be compiler/rustc_llvm/src/ffi/coverageinfo.rs
.
(Same for the neighboring enzyme
module.)
Doing something like this was in my todo list for quite some time, but I expected to turn
look unexpected. |
#17795 expresses a desire to test the LLVM bindings with
ctest
. A pre-requisite for that is to have all the LLVM externs in once place, rather than spread across multiple crates.Actually testing with
ctest
is blocked because the current version ofctest
uses a long out-of-date parser which cannot cope with eg.extern
blocks among other things. However there appears to be active work to build a new version ofctest
(see https://github.com/rust-lang/libc/tree/main/ctest-next)This PR does not intend to change any behaviour, only to move all FFI code into the
rustc_llvm
crate so that it may be tested at some future time.